package com.fjb.config;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.fjb.common.entity.HttpCode;
import com.fjb.common.entity.JsonResult;


/**
 * @Description:全局异常处理
 * @author hm
 * @time:2019年6月29日 下午3:15:15
 */
@ControllerAdvice
public class GloablExceptionHandler {

	@ExceptionHandler(Exception.class)
	@ResponseBody
    public Object handleException(Exception e) {
		// 记录错误信息	
        String msg = e.getMessage();
        if (HttpCode.NO_LOGIN.getMsg().equals(msg)) {
        	// 登录超时
            return new JsonResult<String>(null, HttpCode.NO_LOGIN);
        }	
        e.printStackTrace();
        HttpCode httpCode = HttpCode.EXCEPTIONS;
        return new JsonResult<String>(null, httpCode);
    }
}
